package com.lzx.adx.report.model.proxy;

import com.lzx.adx.report.cache.AccountLocalCache;
import com.lzx.adx.report.dto.AccountDTO;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;


@Data
public class ProxyReq {
    private String dspId;
    private String eventType = "click";
    private String traceTime;
    private String ip;
    private String oaid;
    private String oaidSum;
    private String campaignId = "1001";
    private String adgroupId = "1002";
    private String contentId = "1003";
    private String callback;
    private String requestId;
    private String channel;
    private String tagId;
    private String imei;
    private String userAgent;
    private String imeiSum;
    private String hashAndroidId;
    private String idfa;
    private String idfaSum;
    private String cid;
    private String cidSum;
    private String unionSite;
    private String csite;


    public void checkParam() {
        if (StringUtils.isBlank(dspId)) {
            throw new IllegalArgumentException("dspId参数为空");
        }
        AccountDTO accountDTO = AccountLocalCache.getInstance().get(dspId);
        if (null == accountDTO) {
            throw new IllegalArgumentException("dspId不存在");
        }
        if (StringUtils.isBlank(callback)) {
            throw new IllegalArgumentException("callback参数为空");
        }
        if (StringUtils.isBlank(channel)) {
            throw new IllegalArgumentException("channel参数为空");
        }
        if (StringUtils.isBlank(tagId)) {
            throw new IllegalArgumentException("channel参数为空");
        }
        if (StringUtils.isBlank(oaid) && StringUtils.isBlank(imei)&& StringUtils.isBlank(oaidSum)) {
            throw new IllegalArgumentException("oaid或者imei或者oaidMd5参数为空");
        }
        if (StringUtils.isBlank(traceTime)) {
            traceTime = String.valueOf(System.currentTimeMillis());
        }
    }


}